/*
 * Copyright 2005-2013 biz-united. All rights reserved.
 * Support: http://www.biz-united.com.cn
 * License: http://www.biz-united.com.cn/?page_id=5&act=3
 */
package net.biz.dao.impl;

import net.biz.dao.RoleDao;
import net.biz.entity.Role;

import java.util.List;

import javax.persistence.FlushModeType;
import javax.persistence.TypedQuery;

import org.springframework.stereotype.Repository;

import com.home766.entity.Dictionary;

/**
 * Dao - 角色
 * 
 * @author BIZ Team
 * @version 3.0
 */
@Repository("roleDaoImpl")
public class RoleDaoImpl extends BaseDaoImpl<Role, Long> implements RoleDao {

	@Override
	public Role findByName(String name) {
		// TODO Auto-generated method stub
		
		String jpql = "select role from Role role where role.name=:name  ";
		TypedQuery<Role> query = entityManager.createQuery(jpql, Role.class).setFlushMode(FlushModeType.COMMIT);
		query.setParameter("name", name);
		List<Role> list=query.getResultList();
		Role role=null;
		if(list!=null&&list.size()>0){
			role=list.get(0);
		}
		return role;
	}

}